﻿<!-- 
 Family Lines code is provided using the Apache License V2.0, January 2004 http://www.apache.org/licenses/
  
 -->
<UserControl x:Class="KBS.FamilyLines.Controls.FamilyView.PersonView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:FL="clr-namespace:KBS.FamilyLines"
             xmlns:Properties="clr-namespace:KBS.FamilyLines.Properties" 
             mc:Ignorable="d" 
             x:Name="_this"
             d:DesignHeight="300" d:DesignWidth="300"
>

    <UserControl.Resources>
        <FL:ImageConverter x:Key="ImageConvert" />

        <FL:BoolToVisibilityConverter x:Key="VisiConvert"/>
        
        <FL:ComposingConverter x:Key="ComposingConverter">
            <FL:ComposingConverter.Converters>
                <FL:NotConverter />
                <FL:BoolToVisibilityConverter />
            </FL:ComposingConverter.Converters>
        </FL:ComposingConverter>

        <FL:DateFormattingConverter x:Key="DateConvert"/>
        
    </UserControl.Resources>

    <Grid>
        <Border DataContext="{Binding Path=Human}"
                Name="Border"
                Background="{DynamicResource PanelGradientBrush}"
                Style="{DynamicResource BorderStyle}"
                BorderBrush="#FFFFFFFF" 
                MouseUp="Border_MouseUp"
                ToolTip=""
                ToolTipOpening="Border_ToolTipOpening"
                BorderThickness="1,1,1,1" 
                CornerRadius="10,10,10,10">
            <StackPanel Orientation="Vertical" Margin="5">
                <DockPanel>
                    <StackPanel VerticalAlignment="Top" Margin="0,0,5,10" DockPanel.Dock="Left">
                        <Border BorderBrush="#02747474" Background="#02000000" HorizontalAlignment="Center" 
                                Margin="5,5,5,0" VerticalAlignment="Top" BorderThickness="1,1,1,1" 
                                x:Name="AvatarPhotoBorder"
                                Visibility="{Binding Path=HasAvatar, Converter={StaticResource VisiConvert}, Mode=Default}">
                            <Border.BitmapEffect>
                                <DropShadowBitmapEffect ShadowDepth="7" Softness="0.75" />
                            </Border.BitmapEffect>
                            <Image x:Name="Avatar" Source="{Binding Path=Avatar, Converter={StaticResource ImageConvert}, Mode=OneWay}" Stretch="Uniform" VerticalAlignment="Top" MaxWidth="90" 
                                   Height="85" HorizontalAlignment="Left" StretchDirection="DownOnly" />
                        </Border>
                        <Border x:Name="NoPhotoBorder" Visibility="{Binding Path=HasAvatar, Converter={StaticResource ComposingConverter}, Mode=Default}" BorderBrush="#FFFFFFFF" 
                                Background="#02FFFFFF" Margin="5,5,5,0">
                            <Rectangle Fill="{DynamicResource NoPhotoBrush}" Stroke="{x:Null}" Width="70" Height="85" x:Name="NoPhotoRectangle" VerticalAlignment="Top">
                                <Rectangle.BitmapEffect>
                                    <DropShadowBitmapEffect ShadowDepth="7" Softness="0.75" />
                                </Rectangle.BitmapEffect>
                            </Rectangle>
                        </Border>
                    </StackPanel>
                    <StackPanel DockPanel.Dock="Right" 
                                HorizontalAlignment="Right" 
                                Orientation="Vertical" >

                        <Grid Grid.Row="1" MinWidth="100">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition/>
                                <ColumnDefinition/>
                                <ColumnDefinition/>
                                <ColumnDefinition/>
                                <ColumnDefinition/>
                            </Grid.ColumnDefinitions>

                            <!--grayed out icons-->
                            <Image Margin="-2,0,0,0" Opacity="0.4" HorizontalAlignment="Center"  VerticalAlignment="Center" Source="..\..\Images\Citation.png" Grid.Column="1" Width="16" Height="16" />
                            <Image Margin="-2,0,0,0" Opacity="0.4" HorizontalAlignment="Center"  VerticalAlignment="Center" Source="..\..\Images\Photo.png" Grid.Column="2" Width="16" Height="16"  />
                            <Image Margin="-2,0,0,0" Opacity="0.4" HorizontalAlignment="Center"  VerticalAlignment="Center" Source="..\..\Images\Note.png" Grid.Column="3" Width="16" Height="16" />
                            <Image Margin="-2,0,0,0" Opacity="0.4" HorizontalAlignment="Center"  VerticalAlignment="Center"  Source="..\..\Images\Paperclip.png" Grid.Column="4" Width="16" Height="16" />
                            <Image Margin="4,0,0,0" Opacity="0.4" HorizontalAlignment="Center"  VerticalAlignment="Center"  Source="..\..\Images\SecurityLock.png" Grid.Column="0" Width="16" Height="16" />

                            <!--coloured icons if person has ... -->
                            <Image Margin="-2,0,0,0" HorizontalAlignment="Center" Visibility="{Binding Path=HasCitations, Converter={StaticResource VisiConvert}, Mode=Default}" VerticalAlignment="Center" Source="..\..\Images\Citation.png" Grid.Column="1" Width="16" Height="16" ToolTip="{x:Static Properties:Resources.HasCitations}" />
                            <Image Margin="-2,0,0,0" HorizontalAlignment="Center" Visibility="{Binding Path=HasPhoto, Converter={StaticResource VisiConvert}, Mode=Default}" VerticalAlignment="Center" Source="..\..\Images\Photo.png" Grid.Column="2" Width="16" Height="16" ToolTip="{x:Static Properties:Resources.HasPhotos}" />
                            <Image Margin="-2,0,0,0" HorizontalAlignment="Center" Visibility="{Binding Path=HasNote, Converter={StaticResource VisiConvert}, Mode=Default}" VerticalAlignment="Center" Source="..\..\Images\Note.png" Grid.Column="3" Width="16" Height="16" ToolTip="{x:Static Properties:Resources.HasNotes}" />
                            <Image Margin="-2,0,0,0" HorizontalAlignment="Center" Visibility="{Binding Path=HasAttachments, Converter={StaticResource VisiConvert}, Mode=Default}" VerticalAlignment="Center"  Source="..\..\Images\Paperclip.png" Grid.Column="4" Width="16" Height="16" ToolTip="{x:Static Properties:Resources.HasAttachments}" />
                            <Image Margin="4,0,0,0" HorizontalAlignment="Center" Visibility="{Binding Path=HasRestriction, Converter={StaticResource VisiConvert}, Mode=Default}" VerticalAlignment="Center"  Source="..\..\Images\SecurityLock.png" Grid.Column="0" Width="16" Height="16" ToolTip="{x:Static Properties:Resources.HasRestrictions}" />

                        </Grid>

                    </StackPanel>

                </DockPanel>

                <Label Padding="0" Content="{Binding Path=Name, Mode=OneWay}"/>
                <StackPanel Orientation="Horizontal" Margin="0,5,0,0">
                    <Label Padding="0"
                           Margin="0,0,5,0"
                           Content="{x:Static Properties:Resources.Born}"/>
                    <Label Padding="0" Content="{Binding Path=BirthDate, Mode=OneWay, Converter={StaticResource DateConvert}}"/>
                </StackPanel>
                <Label Padding="0" Content="{Binding Path=BirthPlace, Mode=OneWay}"/>
                <StackPanel Orientation="Horizontal"  Margin="0,5,0,0"
                            Visibility="{Binding Path=IsLiving, Converter={StaticResource ComposingConverter}, Mode=Default}">
                    <Label Padding="0"
                           Margin="0,0,5,0"
                           Content="{x:Static Properties:Resources.Died}"/>
                    <Label Padding="0" 
                           Content="{Binding Path=DeathDate, Mode=OneWay, Converter={StaticResource DateConvert}}"/>
                </StackPanel>
                <Label Padding="0" Content="{Binding Path=DeathPlace, Mode=OneWay}"/>
                
                <StackPanel x:Name="SpouseNav"
                            Margin="5,5,0,0"
                            Orientation="Horizontal"
                            Visibility="{Binding Path=Child, Converter={StaticResource ComposingConverter}, Mode=Default}">
                    <TextBlock Text="{x:Static Properties:Resources.Spouse}"
                               Style="{DynamicResource SectionHeaderStyle}"
                               Margin="5,0,5,0"
                               />
                    <ComboBox x:Name="SpouseList"
                              Style="{DynamicResource FamilyMemberComboBox}"
                              />
                </StackPanel>
            </StackPanel>
            
        </Border>
    </Grid>
</UserControl>
